// 1. js reverse  +  循环比较 
// 2. 双指针  i j 
// 3. 双端队列 不停的出队 

import DoubleQueue from "./double.queue"
function palindromeChecker(aString: string):boolean {
    if ( aString === undefined ||
        aString == null ||
        aString!== null && aString.length == 0    
        ) {
            return false
    }
    // 忽略大小写?
    const lowerString: string = 
        aString.toLocaleLowerCase().split(' ').join('')
    
    const queue:DoubleQueue<string> = new DoubleQueue()
    for (let i = 0, len = lowerString.length; i < len; i++) {
        queue.addBack(lowerString.charAt(i))
    }
    while(queue.size() > 1) {
        if (queue.removeFront() !== queue.removeBack()) {
            return false
        }
    }

    return true
}

console.log(palindromeChecker('ab23456ba'))
